package org.blogwu.learn.multithread.chapter2.demo2;


public class Main {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            while (true) {
                if (Thread.currentThread().isInterrupted()) {
                    System.out.println("Interrupted");
                    break;
                }
                Thread.yield();
            }
            System.out.println("exit");
        });
        t1.start();
        Thread.sleep(3000);
        t1.interrupt();
        Thread.sleep(3000);
        System.out.println(t1.getState());
    }
}
